package com.ruoyi.delivery.service.impl;

import com.ruoyi.delivery.domain.DelDeliveryOrderBatch;
import com.ruoyi.delivery.mapper.DelDeliveryOrderMapper;
import com.ruoyi.delivery.service.IDelDeliveryOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DelDeliveryOrderServiceImpl implements IDelDeliveryOrderService {

    @Autowired
    private DelDeliveryOrderMapper deliveryOrderMapper;

    /**
     * 根据条件分页查询配送单信息
     *
     * @param logisticId    物流商编号
     * @param deliveryId    配送单号
     * @param origin        发源地
     * @param state         状态
     * @param startDate     创建时间开始范围
     * @param endDate       创建时间结束范围
     * @param vehicleNumber 车辆编码
     * @param deliveryType  配送单类型
     * @param offset        分页偏移量
     * @param pageSize      分页大小
     * @return 配送单信息列表
     */
    @Override
    public List<DelDeliveryOrderBatch> getDeliveryOrders(String logisticId, String deliveryId, String origin, String state,
                                                         String startDate, String endDate, String vehicleNumber, String deliveryType,
                                                         int offset, int pageSize) {
        return deliveryOrderMapper.getDeliveryOrders(logisticId, deliveryId, origin, state, startDate, endDate, vehicleNumber, deliveryType, offset, pageSize);
    }

    /**
     * 获取配送单总记录数
     *
     * @param logisticId    物流商编号
     * @param deliveryId    配送单号
     * @param origin        发源地
     * @param state         状态
     * @param startDate     创建时间开始范围
     * @param endDate       创建时间结束范围
     * @param vehicleNumber 车辆编码
     * @param deliveryType  配送单类型
     * @return 总记录数
     */
    @Override
    public int getDeliveryOrderCount(String logisticId, String deliveryId, String origin, String state,
                                     String startDate, String endDate, String vehicleNumber, String deliveryType) {
        return deliveryOrderMapper.getDeliveryOrderCount(logisticId, deliveryId, origin, state, startDate, endDate, vehicleNumber, deliveryType);
    }

    /**
     * 更新配送单信息
     *
     * @param deliveryOrderBatch 配送单信息对象
     * @return 更新影响的行数
     */
    @Override
    public int updateDeliveryOrderInfo(DelDeliveryOrderBatch deliveryOrderBatch) {
        return deliveryOrderMapper.updateDeliveryOrder(deliveryOrderBatch);
    }

    /**
     * 删除单个配送单
     * @param deliveryId 配送单号
     * @return 删除影响的行数
     */
    @Override
    public int deleteDeliveryOrder(String deliveryId) {
        return deliveryOrderMapper.deleteDeliveryOrder(deliveryId);
    }

    /**
     * 新增配送单信息
     * @param deliveryOrder 配送单信息对象
     * @return 插入影响的行数
     */
    @Override
    public int insertDeliveryOrder(DelDeliveryOrderBatch deliveryOrder) {
        return deliveryOrderMapper.insertDeliveryOrder(deliveryOrder);
    }

}
